export interface WorkflowGraph {
  data: any
}

export interface WorkflowListSearch {
  name?: string
  version?: string | number
}

export interface GraphData {
  name?: string
  version?: string | number
  input?: any
}

// 新增或更新流程
export function addOrUpdate(params: WorkflowGraph) {
  return usePost<WorkflowGraph>('/metadata/registerOrUpdateByGraph', params.data, {
    customDev: true,
  })
}

// 流程列表
export function workflowList(params: WorkflowListSearch) {
  return usePost<WorkflowListSearch>('/metadata/workflowList', params, {
    customDev: true,
  })
}

// 流程图详情
export function graphWorkflow(params: GraphData) {
  return useGet<GraphData>(`/metadata/graphWorkflow/${params.name}/${params.version}`, null, {
    customDev: true,
  })
}

// 开始流程
export function startWorkflow(params: GraphData) {
  return usePost(`/metadata/startWorkflow/${params.version}/${params.name}`, null, {
    customDev: true,
  })
}

// 带入参开始流程
export function startWithInput(params: GraphData) {
  return usePost(`/metadata/startWithInput/${params.version}/${params.name}`, params.input, {
    customDev: true,
  })
}
